<template>
  <ul class="category-list">
    <li 
      v-for="category in categories" 
      :key="category.categoryId"  
      class="category-item"
    >
      <router-link 
        :to="`/category/${category.categoryId}?name=${encodeURIComponent(category.categoryName)}`" 
        class="category-link"
      >
        <el-icon class="category-icon"><Folder /></el-icon>
        <span class="category-name">{{ category.categoryName }}</span>
        <span class="category-count">({{ category.articleCount || 0 }})</span>
      </router-link>
    </li>
  </ul>
</template>

<script setup>
import { Folder } from '@element-plus/icons-vue'

defineProps({
  categories: {
    type: Array,
    default: () => []
  }
})
</script>

<style scoped>
/* 保持原有样式不变 */
.category-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.category-item {
  margin-bottom: 0.5rem;
}

.category-link {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  color: #34495e;
  text-decoration: none;
  border-radius: 3px;
  transition: background-color 0.3s ease;
}

.category-icon {
  margin-right: 0.5rem;
  color: #7f8c8d;
  font-size: 1rem;
}

.category-link:hover {
  background-color: #f5f5f5;
}

.router-link-active.category-link {
  background-color: #42b983;
  color: white;
}

.router-link-active.category-link .category-icon {
  color: white;
}

.category-name {
  flex-grow: 1;
}

.category-count {
  margin-left: 0.5rem;
  color: #7f8c8d;
  font-size: 0.9em;
}
</style>